const util = require('../../utils/util')
const app = getApp()

Page({
  data: {
    api: app.globalData.api,
    productlist:[], 
    checkinfo:"",
  },
  detail(e){
    //var 是局部变量
    var item = e.currentTarget.dataset.check
    console.log("checkkkkkk")
    console.log(item)  //这里传的是商品信息：category, cid ctime ftime hot id logo num price product uid user
    console.log("checkk")
    //存到本地直到软件卸载
    wx.setStorageSync('商品信息', item)
    //打开新的小程序页面
    util.redirect('detail')
  },
  onLoad(options) {
    this.data.checkinfo = wx.getStorageSync('查询内容')
    console.log("checkinfo")
    console.log(this.data.checkinfo)
    util.http('/product/search?key='+this.data.checkinfo, resp=>{
      console.log(resp);
      this.data.productlist = resp;
      console.log(this.data.productlist)
      this.setData(this.data)
    })
  }
})